using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FairyGUI;

namespace Wwo
{
    public class UISets
    {
        public BackWndView m_BackWndView;
        public MapWndView m_MapWndView;
        public GameLoginView m_GameLoginView;
        public NewWorldView m_NewWorldView;
        public LoadWorldView m_LoadWorldView;
        public CreateRole m_CreateRole;
        public MainMenuView m_MainMenuView;
        public WorkMgrView m_WorkMgrView;
        public NpcListView m_NpcListView;
        public ResListView m_ResListView;
        public JianZhuView m_JianZhuView;
        public SysMenuView m_SysMenuView;
        public YeShengList m_YeShengList;

        public List<Window> m_List;

        public string m_BuildItem;
        public int m_BuildItemParam;

        public static UISets GetInstance()
        {
            return Singleton<UISets>.Instance;
        }

        public UISets()
        {
            m_List = new List<Window>();

            m_BackWndView = new BackWndView();
            m_List.Add(m_BackWndView);

            m_MapWndView = new MapWndView();
            m_List.Add(m_MapWndView);

            m_GameLoginView = new GameLoginView();
            m_List.Add(m_GameLoginView);

            m_NewWorldView = new NewWorldView();
            m_List.Add(m_NewWorldView);

            m_LoadWorldView = new LoadWorldView();
            m_List.Add(m_LoadWorldView);

            m_CreateRole = new CreateRole();
            m_List.Add(m_CreateRole);

            m_MainMenuView = new MainMenuView();
            m_List.Add(m_MainMenuView);

            m_WorkMgrView = new WorkMgrView();
            m_List.Add(m_WorkMgrView);

            m_NpcListView = new NpcListView();
            m_List.Add(m_NpcListView);

            m_ResListView = new ResListView();
            m_List.Add(m_ResListView);

            m_JianZhuView = new JianZhuView();
            m_List.Add(m_JianZhuView);

            m_SysMenuView = new SysMenuView();
            m_List.Add(m_SysMenuView);

            m_YeShengList = new YeShengList();
            m_List.Add(m_YeShengList);

        }

        // 仅仅显示 谁s
        public void OnlyShow(params Window[] wObj)
        {
            for (int i = 0; i < m_List.Count; i++)
            {
                for (int k = 0; k < wObj.Length; k++)
                {
                    if (m_List[i] != null && m_List[i] != wObj[k])
                    {
                        m_List[i].Hide();
                    }
                }
            }

            for (int k = 0; k < wObj.Length; k++)
            {
                if (wObj[k] != null)
                {
                    wObj[k].Show();
                }
            }
        }

        // 开关显示 谁s
        public void SwitchShow(params Window[] wObj)
        {
            for (int k = 0; k < wObj.Length; k++)
            {
                if (wObj[k] != null)
                {
                    if (GRoot.inst.GetChildIndex(wObj[k]) != -1)
                    {
                        wObj[k].Hide();
                    }
                    else
                    {
                        wObj[k].Show();
                    }
                }
            }
        }

        public bool HasBuildItem()
        {
            return m_BuildItem != "";
        }

        public string GetBuildItem()
        {
            return m_BuildItem;
        }

        public void SetBuildItem(string name)
        {
            bool change = (m_BuildItem != name);

            if (!change)
                return;

            m_BuildItem = name;

            switch (m_BuildItem)
            {
                case "取消":
                    m_BuildItemParam = 0;
                    StateManager.GetInstance().ChangeState(ControlState.ecs_Del, m_BuildItemParam);
                    break;
                case "地基":
                    m_BuildItemParam = 0;
                    StateManager.GetInstance().ChangeState(ControlState.ecs_Ground, m_BuildItemParam);
                    break;
                case "墙":
                    m_BuildItemParam = 0;
                    StateManager.GetInstance().ChangeState(ControlState.ecs_BuildingWoodenWall, m_BuildItemParam);
                    break;
                case "桌子":
                    m_BuildItemParam = 0;
                    StateManager.GetInstance().ChangeState(ControlState.ecs_Goods, m_BuildItemParam);
                    break;
                case "单人床":
                    m_BuildItemParam = 1;
                    StateManager.GetInstance().ChangeState(ControlState.ecs_Goods, m_BuildItemParam);
                    break;
                case "":
                    m_BuildItemParam = 0;
                    StateManager.GetInstance().ChangeState(ControlState.ecs_None, m_BuildItemParam);
                    break;
            }
        }
    }
}

